"""
猜数字，设定一个理想数字比如：66，让用户输入数字，如果比66大，
则显示猜测的结果大了,然后继续让用户输入;
如果比66小，则显示猜测的结果小了,然后继续让用户输入;
只有等于66，显示猜测结果正确，然后退出循环。
"""
# age = 66
# while True:
#     age_input = int(input("请输入数字:"))
#     if age_input > age:
#         print("大了")
#     elif age_input < age:
#         print("小了")
#     else:
#         print("正确")
#         break

"""
在上一题的基础，设置：给用户三次猜测机会，如果三次之内猜测对了，则显示猜测正确，
退出循环，如果三次之内没有猜测正确，则自动退出循环，并显示‘大笨蛋’
"""

# count = 1  #计数器
# age = 66
# while count < 4:
#     age_input = int(input("请输入数字："))
#     if age_input > age:
#         print("大了")
#     elif age_input < age:
#         print("小了")
#     else:
#         print("正确")
#         break
#     count += 1
# else:
#     print("大笨蛋")

# print(1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6)
# not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6

# 使用while循环输出 1 2 3 4 5 6 8 9 10

# count = 1
# while count < 11:
#     if count == 7:
#         count += 1
#     print(count)
#     count += 1

# count = 0
# while count < 10:
#     count += 1
#     if count == 7:
#         continue
#     print(count)

# 输出 1-100 内的所有奇数

# count = 1
# while count < 101:
#     if count % 2 != 0:
#         print(count)
#     count += 1

# 求+1-2+3-4+5 ... 99的所有数的和

# count = 1
# num_sum = 0  # 偶数的减和
# sum_num = 0  # 奇数的加和
# while count < 100:
#     if count % 2 == 0:
#         num_sum = num_sum - count
#     else:
#         sum_num = sum_num + count
#     count +=1
#
# print(num_sum + sum_num)


# count = 1
# num_sum = 0  # 总和
# while count < 100:
#     if count % 2 == 0:
#         num_sum = num_sum - count
#     else:
#         num_sum = num_sum + count
#     count +=1
#
# print(num_sum)


"""
猜年龄游戏升级版 要求：允许用户最多尝试3次，每尝试3次后，如果还没猜对，
就问用户是否还想继续玩，如果回答Y，就继续让其猜3次，
以此往复，如果回答N，就退出程序，如何猜对了，就直接退出。
"""

# count = 1
# age = 66
# while count < 4:
#     age_input = int(input("请输入年龄："))
#     if age_input > age:
#         print("大了")
#     elif age_input < age:
#         print("小了")
#     else:
#         print("猜对了")
#         break
#
#     if count == 3:
#         choice = input("是否继续（Y/N）：")
#         if choice == "Y":
#             count = 0
#         else:
#             break

    # count += 1

# ⽤户登陆（三次输错机会）且每次输错误时显示剩余错误次数（提示：使⽤字符串格式化）

# count = 3
#
# while count > 0:
#     user = input("user:")
#     pwd = input("password:")
#     if user == 'alex' and pwd == 'alex3714':
#         print("登录成功！")
#         break
#     else:
#         print(f"你是Alex吗?这都记不住！剩余次数{count - 1}")
#     count -= 1

